<?php

namespace app\api\model\wanlshop;

use think\Model;
use traits\model\SoftDelete;

class Pay extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'wanlshop_pay';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';
	
	//写入 order_pay_no
	protected function setPayNoAttr($value)
	{
		// 高并发有几率重复，暂时不需要
	    return date('YmdHis').substr(strrev($value),-8).substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 8);
	}
	
    public static function getTypePay($type){
        // 订单类型:goods=商品订单,groups=拼团订单,sys=平台订单
        $arr = ['goods','groups','sys'];
        return in_array($type,$arr) ? $type:'pay';
    }
	public static function getTypeName($type){
       // 订单类型:goods=商品订单,groups=拼团订单,sys=平台订单
	   $arr = ['goods'=>'商城订单','groups'=>'拼团订单','sys'=>'平台订单','activity'=>'活动订单'];
	   return isset($arr[$type]) ? $arr[$type] : "商城订单";
    }
}